
<?php
require_once './model/db.php';

$query = sprintf("SELECT * FROM pages LIMIT");
$pages = getPages($query);
$companies = getCompanies("SELECT * FROM companies");
$apps = getApps("SELECT * FROM apps");



?>
<form method="POST">
   
  
    Min Like : <input type="text" name="Min"><br>
    Max Like : <input type="text" name="Max"><br>
    Keyword  : <input type="text" name="keyword"><br>
      Company  :  <select name="Company">
     
        <?php foreach ($companies as $company): ?>
            <option value="<?php echo $company['id'] ?>"><?php echo $company["name"] ?></option>
        <?php endforeach; ?>
    </select> <br>
    App :<select name="App">
    
        <?php foreach ($apps as $app): ?>
            <option value="<?php echo $app['pid'] ?>"><?php echo $app["name"] ?></option>
        <?php endforeach; ?>
    </select> <br>
    <input type="submit" name="submit" value="Search">
</form>
<?php if (isset($_POST['submit'])): ?>
<?php
$Min=$_POST['min'];
$Max=$_POST['max'];
$Keyword=$_POST['keyword'];?>?>

<table border ="1">
    <tr>
   
        <th>ID</th>
        <th>Pid</th>
        <th>Name</th>
        <th>Username</th>
        <th>Phone</th>
        <th>Like</th>
         <th>Picture</th>
        
    </tr>
    
<?php foreach ($pages as $page): ?>
    <tr><?php if((int)$_GET.$page['likes']>= ((int)$_POST['min'])&&(int)$_GET.$page['likes']<=(int)$_POST['max']): ?>
  
        <td><?php echo $page['pid'] ?></td>
        <td><?php echo $page['id'] ?></td>
        <td><?php echo $page['name'] ?></td>
        <td><?php echo $page['username'] ?></td>
        <td><?php echo $page['phone'] ?></td>
        <td><?php echo $page['likes']?></td>
        <td><img src='<?php echo $page['picture']?>'></td>
        
    </tr>
<?php endif;?>
<?php endforeach; ?>
    <?php endif;?>
</table>